<?php
/**
 * Created by PhpStorm.
 * User: Tsang
 * Date: 2017/9/24 16:20
 *
 */

namespace app\api\model;

use think\Model;

class UserAccount extends Model
{
   /**
     * 获取用户
     */
    public function getUser($where = '')
    {
        $user = $this->where($where)->find();
       
        return $user;
    }
    /**
     * 获取所有用户
     */
    public function getUserAll($where='')
    {
        $userAll = $this->where($where)->select();
        return $userAll;
    }
    /**
     * 添加用户
     */
    public function addUser($data = [])
    {
        $id = $this->insertGetId($data);
        return $id;
    }
    /**
     * 修改用户资料
     */
    public function modifyUser($where='',$data = [])
    {
        $res = $this->where($where)->update($data);
        return $res;
    }
    /**
     * 修改用户密码
     */
    public function modifyPassword($where='',$data = [])
    {
        $res = $this->where($where)->update($data);
        return $res;
    }
    //hash密码
    public function add_hash($pass){
          return password_hash($pass,PASSWORD_BCRYPT);
    }

    //验证密码
    public function verification_hash($pass,$hash){
          return password_verify($pass,$hash);
    }
}